package org.jeecg.modules.yks.dev.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.yks.dev.entity.YksEquipment;
import org.jeecg.modules.yks.dev.mapper.YksEquipmentMapper;
import org.jeecg.modules.yks.dev.service.IYksEquipmentService;
import org.jeecg.modules.yks.mng.entity.YksEquipmentManageUsers;
import org.jeecg.modules.yks.mng.mapper.YksEquipmentManageUsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 设备主表
 * @Author: jeecg-boot
 * @Date:   2023-11-23
 * @Version: V1.0
 */
@Service
public class YksEquipmentServiceImpl extends ServiceImpl<YksEquipmentMapper, YksEquipment> implements IYksEquipmentService {

   @Autowired
   YksEquipmentMapper yksEquipmentMapper;

   @Autowired
   YksEquipmentManageUsersMapper yksEquipmentManageUsersMapper;

    @Override
    public IPage<YksEquipment> listPage(Wrapper<YksEquipment> wrapper, Page<YksEquipment> page) {
        return yksEquipmentMapper.listPage(page, wrapper);
    }
    @Override
    public List<YksEquipment> listPage(Wrapper<YksEquipment> wrapper) {
        return yksEquipmentMapper.listPage(wrapper);
    }

    @Override
    public void saveMain(YksEquipment yksEquipment) {
        yksEquipmentMapper.insert(yksEquipment);
        YksEquipmentManageUsers manageUsers = new YksEquipmentManageUsers();
        manageUsers.setEquipmentId(yksEquipment.getId());
        manageUsers.setUserId("apadmin");
        yksEquipmentManageUsersMapper.insert(manageUsers);
        manageUsers = new YksEquipmentManageUsers();
        manageUsers.setEquipmentId(yksEquipment.getId());
        manageUsers.setUserId("ykadmin");
        yksEquipmentManageUsersMapper.insert(manageUsers);
        manageUsers = new YksEquipmentManageUsers();
        manageUsers.setEquipmentId(yksEquipment.getId());
        manageUsers.setUserId(yksEquipment.getCreateBy());
        yksEquipmentManageUsersMapper.insert(manageUsers);
    }
}
